<template>
  <Dialog :title="dialogTitle" class="uploadDialog" v-model="dialogVisible">
    <div class="wrap w-full h-full ">
      <UploadFileList class="w-[60%] h-full" v-model="fileList" @uploaded="getFileList" :quoteNumber="qn" />
    </div>
    <template class="mb-0" #footer>
      <el-button @click="closeModal">关 闭</el-button>
    </template>
  </Dialog>

</template>

<script setup lang="ts">
import { QuotationApi } from '@/api/quote/quotation'

let fileList = ref()
let dialogTitle = ref('附件上传')
let dialogVisible = ref(false)
let qn = ref('')

/** 报价单 表单 */
defineOptions({ name: 'uploadForm' })

// 关闭弹窗
const closeModal = () => {
  dialogVisible.value = false
  fileList.value = []
  qn.value = ''
}

async function getFileList(quoteNumber) {
  fileList.value = await QuotationApi.getAttachmentListByQuotationNo(quoteNumber);
}


/** 打开弹窗 */
const open = async (type, row) => {
  dialogVisible.value = true
  qn.value = row.quoteNumber
  await getFileList(row.quoteNumber);

}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
onMounted(async () => {

})

nextTick(() => {
})
</script>

<style lang="scss" scoped>
.wrap {
  :deep() {
    .el-upload-list__item:nth-child(n + 2) {
      display: none !important;
    }
  }
}
</style>
